package apis

import (
	"gitee.com/sansaniot/ssiot-core/httpmvc/api"
	"gitee.com/sansaniot/ssiot-core/serrors"
	"github.com/gin-gonic/gin"
	"ssadmin/internal/admin/service"
)

type SysApi struct {
	api.Api
}

// 查询系统API记录
func (e SysApi) FindSysApiTree(c *gin.Context) {
	s := service.SysApi{}
	err := e.MakeContext(c).
		MakeOrm().
		MakeService(&s.Service).
		Errors
	if err != nil {
		e.Logger.Error(err)
		e.Fail(serrors.Fail)
		return
	}
	//获取机构
	err, dataMap := s.GetTree()
	if err != nil {
		e.Logger.Error(err)
		e.Fail(serrors.Fail)
		return
	}
	e.Data(dataMap)
}
